package lk.icta.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author Supun Viraj Rathnayaka
 */

public class CommonUtil {

    private static final Logger logger = LoggerFactory.getLogger(CommonUtil.class);

    /**
     * Returns the Date from the date string with YYYY-MM-DD format
     * @param dt
     * @return Date
     */
    public static Date getDate(String dt){
        Date date = null;
        try {
            date = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH).parse(dt);
        } catch (ParseException e) {
            logger.error("Error in parsing the date {}", dt);
        }
        return date;
    }

}
